// 存储路由路径
const ADDROUTINGPATHDATA = 'ADDROUTINGPATHDATA'
// 移除路由路径
const REMOVEROUTINGPATHDATA='REMOVEROUTINGPATHDATA'

export default {
    namespaced:true,
    state:{
        RoutingPathData:[
            {title:"后台首页",path:"/welcome"}
        ]
    },
    mutations:{
        // 存储路由路径
        [ADDROUTINGPATHDATA] (state, {params}) {
            // 判断RoutingPathData内是否存在新的路由不存在则插入
            console.log(params);
            if(params.path=="/welcome"){
                return
            }
            let flag = true
            for (let i=0; i<state.RoutingPathData.length; i++) {
                if (state.RoutingPathData[i].path == params.path) {
                flag = false
                break
                }
            }
            if (flag) {
                state.RoutingPathData.push(params)
            }
        },
        //移除路由路径
        [REMOVEROUTINGPATHDATA] (state, {data}) {
            state.RoutingPathData.map((item, index) => {
                if (item.path == data) {
                state.RoutingPathData.splice(index,1)
                }
            })
        }
    },
    actions:{
        // 存储路由路径
        addRoutingPathData ({commit}, params) {
            commit(ADDROUTINGPATHDATA, {params})
        },
        // 移除路由路径
        removeRoutingPathData({commit}, data) {
            commit(REMOVEROUTINGPATHDATA, {data})
        }
    },
    getters:{

    }
}


